﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <link rel="stylesheet" href="../../Scripts/zTree/css/demo.css" type="text/css" />
    <link rel="stylesheet" href="../../Scripts/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css" />

    <script type="text/javascript" src="../../Scripts/zTree/js/jquery-1.4.4.min.js"></script>

    <script type="text/javascript" src="../../Scripts/zTree/js/jquery.ztree.core-3.0.js"></script>

    <script type="text/javascript" src="../../Scripts/zTree/js/jquery.ztree.excheck-3.0.js"></script>

    <script type="text/javascript">
        var setting = {
	        check: {
		        enable: true,
		        chkStyle: "checkbox",
		        chkboxType: { "Y": "s", "N": "s" }
	        },
	        callback:{
	            onCheck:totalClr
	        }
		};
       var zNodes = <%= ViewData["treedefi"]%>; 
       var visible=<%= ViewData["treevisible"]%>; 
		$(function() {
//		        $.fn.zTree.init($("#treeDemo"), setting, zNodes);
//		        if(!treevisible){
//		            $("#treeDemo").hide();
//		        }
		});
		
				
        //统计tree上选中的人员，将其组成一个字符串数组存放在 id=selectarr 隐藏标签中
        function totalClr(event, treeId, treeNode) {
            //alert(treeNode.id + ", " + treeNode.name + "," + treeNode.checked);
            var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
            var nodes = treeObj.getCheckedNodes(true);
            var temp="";
            for (i=0;i<nodes.length ;i++) {
                  temp=temp+nodes[i].id+",";
            }
            $("#selectarr").attr("value",temp); 
        };
        
        function getTable(btnTag) {
            var hidValue;
            var txtValue = "";
            var txtValForData = "";
            var complete = true;
                        
            var tableTag = $(btnTag).parent();
            var childTag = $(tableTag).children();

            childTag.each(function() {
                var cls = $(this).attr("class");
                if (cls == "txtTable") {
                    var txt = $(this).val();
                    var name = $(this).attr("name");
                    if (txt == "")
                        complete = false;
                    txtValue += txt + ";";
                    txtValForData += name + "-" + txt + ";";
                }
                else if (cls == "hidTable")
                    hidValue = $(this).val();
            });
            
            if (!complete) {
                alert("必须填写完整条件");
                return;
            }

            $("#sqlargs").val(txtValue);
            
            $.ajax({
                type: "POST",
                url: "/Form/QueryTable",
                data: { "txtValue": txtValue, "sqlValue": hidValue },
                success: function(data) {
                    if (data == "none") {
                        alert("无所需查询结果");
                    } else {
                        $("#updateTable").html(data);
                    }
                }
            });
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <div id="menus">
            <%using (Html.BeginForm("WFStartManage", "WorkFlow"))
              { %>
            <input type="submit" value="完成并发送" />
            <br />
            流程命名：<%=Html.TextBox("wf_name") %>
            <%=Html.Hidden("form_id",ViewData["form_id"])  %>
            <%=Html.Hidden("wftemplate_id", ViewData["wftemplate_id"])%>
            <%=Html.Hidden("wf_id", ViewData["wf_id"])%>
            <%=Html.Hidden("selectarr", ViewData["clrs"])%>
            <%=Html.Hidden("treedefi",ViewData["treedefi"]) %>
            <%=Html.Hidden("treevis",ViewData["treevisible"]) %>
            <%=Html.Hidden("sqlargs") %>
            <div id="div_bd" style="position: relative; width: 80%; height: 750px; border: solid 1px;">
                <% Response.Write(ViewData["formdefi"]); %>
            </div>
            <div id="div_tree" class="zTreeDemoBackground left" style="padding-top: 500px">
                <ul id="treeDemo" class="ztree">
                </ul>
            </div>
            <%} %>
        </div>
    </div>
</asp:Content>
